import { app } from "@/api/index";
const state = {
  taglist: {}
}

const mutations = {
  SET_TAGLIST: (state, taglist) => {
    state.taglist = taglist
  }
}

const actions = {
  gettaglist({ commit, dispatch }, param) {
    return new Promise((resolve, reject) => {
      if (!state.taglist.default) {
        app().then((data) => {
          let taglist = data.data;
          commit('SET_TAGLIST', taglist)
          resolve()
        }).catch((e => {
          reject(e)
        }))
      } else {
        resolve()
      }
    })
  },
  updatetaglist({ commit, dispatch }, param) {
    return new Promise((resolve, reject) => {
      app().then((data) => {
        let taglist = data.data;
        commit('SET_TAGLIST', taglist)
        resolve()
      }).catch((e => {
        reject(e)
      }))

    })
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
